<?php
/**
 * Created by PhpStorm.
 * User: 勇林
 * Date: 2015/11/17
 * Time: 16:57
 */
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
?>
<script type="text/javascript" src="js/qiniuupload/jquery-1.9.1.min.js"></script>
<div class="text-center">
    <?php
    $weaccounts = \app\models\GkyWeAccount::find()->all();
    echo Html::dropDownList(
        'weixin',
        null,
        ArrayHelper::map($weaccounts,'id','wename'),
        ['class' => 'dropdownlist']
    )
    ?>
</div>

<div class="text-center">
    <img style="width: 300px;height: 300px" id="qrcode_img" src="img/qrcode_for_gh_bba9c29ca948_1280.jpg">
</div>

<script>
    $(document).ready(function() {
        $('.dropdownlist').change(function () {
            $("#qrcode_img").attr("src",'');
            $.ajax({
                url: '?r=gky-we-account/qrcode',
                type: 'post',
                data: {id:$(this).children('option:selected').val()},
                dataType:'json',
                success: function (data) {
                    $("#qrcode_img").attr("src",data.qrcode);
                }
            });
        });
    })
</script>